package com.hz.user.service.impl;

import com.hz.base.service.impl.BaseService;
import com.hz.beans.user.entity.TCounselling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hz.user.mapper.TCounsellingMapper;
import com.hz.user.service.inf.ITCounsellingService;

import java.util.List;

/**
 * TCounsellingService
 * @author liul
 * @since [0.0.1]
 * @version [0.0.1,2018年09月20日]
 */
@Service("tCounsellingService")
public class TCounsellingService extends BaseService<TCounselling> implements ITCounsellingService{
	
	protected Logger log = LoggerFactory.getLogger(TCounsellingService.class);
	
	@Autowired
	private TCounsellingMapper tCounsellingMapper;
    
	 /**
	  * @Author mcz
	  * @Description  查询订单状态
	  * @Date 2018/11/7 11:24
	  * @Param 
	  * @return 
	  **/
	@Override
	public List<TCounselling> queryPayStatus(TCounselling tCounsellings) {
		List<TCounselling> tCounselling= null;
		try {
			tCounselling = tCounsellingMapper.queryPayStatus(tCounsellings);
			/*
			* 验证回调接口的订单是否存在，如果存在且付款成功，
			* 那么在数据库订单表中修改该订单属性为成功状态
			* */
			if(!tCounselling.isEmpty()&&tCounselling.size()==1){
				tCounsellings.setPayMoney(null);
				tCounsellings.setOrderNo(null);
				tCounsellings.setPayStatus("1");
				tCounsellings.setId(tCounselling.get(0).getId());
				int updateFlag=tCounsellingMapper.updateByPrimaryKey(tCounsellings);
			}
		} catch (Exception e) {
			log.error("查询订单异常{}",e);
		}
		return tCounselling;
	}
}
